using System.IO;


namespace Ultima {
  public class Verdata {
    private static readonly Entry5D[] m_Patches;
    private static readonly Stream m_Stream;

    static Verdata() {
      string path = Client.GetFilePath( "verdata.mul" );

      if ( path == null ) {
        m_Patches = new Entry5D[0];
        m_Stream = Stream.Null;
      } else {
        m_Stream = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Read );
        var bin = new BinaryReader( m_Stream );

        m_Patches = new Entry5D[bin.ReadInt32()];

        for ( int i = 0; i < m_Patches.Length; ++i ) {
          m_Patches[i].file = bin.ReadInt32();
          m_Patches[i].index = bin.ReadInt32();
          m_Patches[i].lookup = bin.ReadInt32();
          m_Patches[i].length = bin.ReadInt32();
          m_Patches[i].extra = bin.ReadInt32();
        }
      }
    }

    public static Stream Stream {
      get { return m_Stream; }
    }
    public static Entry5D[] Patches {
      get { return m_Patches; }
    }
  }


  public struct Entry5D {
    public int extra;
    public int file;
    public int index;
    public int length;
    public int lookup;
  }
}